home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1997 July / macformat52.iso / mac / Shareware Plus / Developers / YAAF v1.0 alpha 1 / (Sources) / Standard Controls / Factory / XGIStdClassFactory.cpp < prev   
Encoding:
C/C++ Source or Header  |  1997-04-24  |  3.1 KB  |  120 lines

  1. /*    XGIStdClassFactory.cpp
  2.  *
  3.  *        The class factory for my standard controls
  4.  */
  5.  
  6. /*  YAAF - Yet another application framework
  7.  *  Copyright (C) 1997 William Edward Woody and In Phase Consulting
  8.  *  
  9.  *  This library is free software; you can redistribute it
  10.  *  and/or modify it under the terms of the GNU Library
  11.  *  General Public License as published by the Free Software
  12.  *  Foundation; either version 2 of the License, or any
  13.  *  later version.
  14.  *  
  15.  *  This library is distributed in the hope that it will be
  16.  *  useful, but WITHOUT ANY WARRANTY; without even the implied
  17.  *  warranty of MERCHANTABIILITY or FITNESS FOR A PARTICULAR
  18.  *  PURPOSE. See the GNU Library General Public License for
  19.  *  more details.
  20.  *  
  21.  *  You should have received a copy of the GNU Library General
  22.  *  Public License along with this library; if not, write to the
  23.  *  Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  24.  *  Boston, MA 02111-1307, USA.
  25.  *  
  26.  *  To contact the author, either e-mail me at
  27.  *  woody@alumni.caltech.edu, or write to us at
  28.  *  
  29.  *          William Edward Woody
  30.  *          In Phase Consulting
  31.  *          1545 Ard Eevin Avenue
  32.  *          Glendale, CA 91202
  33.  */
  34.  
  35. #include "factory.h"
  36. #include <XStdControls.h>
  37. #include <XStdButtons.h>
  38. #include <XStdScroll.h>
  39. #include <XStdScrollView.h>
  40. #include <XStdText.h>
  41. #include <XStdImage.h>
  42. #include <XStdList.h>
  43.  
  44. /************************************************************************/
  45. /*                                                                        */
  46. /*    Globals                                                                */
  47. /*                                                                        */
  48. /************************************************************************/
  49.  
  50. static XGIStdClassFactory *GClass;
  51.  
  52. /************************************************************************/
  53. /*                                                                        */
  54. /*    Factory                                                                */
  55. /*                                                                        */
  56. /************************************************************************/
  57.  
  58. /*    XGIStdClassFactory::CreateView
  59.  *
  60.  *        Create view factory
  61.  */
  62.  
  63. XGView *XGIStdClassFactory::CreateView(long type, XGView *view, XGArgStream &stream)
  64. {
  65.     switch (type) {
  66.         case 'pbtn':
  67.             return new XGStdPushButton(view,stream);
  68.         case 'cbtn':
  69.             return new XGStdCheckButton(view,stream);
  70.         case 'rbtn':
  71.             return new XGStdRadioButton(view,stream);
  72.         case 'scrl':
  73.             return new XGStdScroll(view,stream);
  74.         case 'text':
  75.             return new XGStdStaticText(view,stream);
  76.         case 'edit':
  77.             return new XGStdEditText(view,stream);
  78.         case 'grou':
  79.             return new XGStdGroupBox(view,stream);
  80.         case 'pict':
  81.             return new XGStdPicture(view,stream);
  82.         case 'icon':
  83.             return new XGStdIcon(view,stream);
  84.         case 'list':
  85.             return new XGStdListBox(view,stream);
  86.  
  87.         case 'scrv':
  88.             return new XGScrollView(view,stream);
  89.  
  90.         default:
  91.             return NULL;
  92.     }
  93. }
  94.  
  95. /************************************************************************/
  96. /*                                                                        */
  97. /*    External routines                                                    */
  98. /*                                                                        */
  99. /************************************************************************/
  100.  
  101. /*    XGKillStandardControls
  102.  *
  103.  *        Kill my standard control factory
  104.  */
  105.  
  106. void XGKillStandardControls(void)
  107. {
  108.     if (GClass) delete GClass;
  109. }
  110.  
  111. /*    XGInitStandardControls
  112.  *
  113.  *        Standard control factory
  114.  */
  115.  
  116. void XGInitStandardControls(void)
  117. {
  118.     GClass = new XGIStdClassFactory;
  119. }
  120.